import com.android.datastruct.ArrayMap;

import java.util.*;
import java.util.concurrent.Executors;

public class Master {


    public static void main(String[] args) {


        LinkedHashMap<String,String> linkedHashMap = new LinkedHashMap<>();
        String put = linkedHashMap.put("a", "A");
        System.out.println("Master.main put "+ put);
        put = linkedHashMap.put("a", "B");
        System.out.println("Master.main put "+ put);
        put = linkedHashMap.put("a", "C");
        System.out.println("Master.main put "+ put);


//        int c = 0;
//
//        System.out.println("Master ~c "+(~c));
//
//        System.out.println("Master ~~c "+(~(~c)));
//
//        System.out.println("Master 2<<1:"+(2<<1));
//
//        String[] active = new String[0];
//        active = new String[5];
//
//        final String[] ss = active;
//        for (int i = 0; i < 5; i++) {
//            ss[i] = i+"";
//        }
//
//        System.out.println("Master.main active "+active);
//
//        int[] a ={1,2,3,4,5,6,10};
//
//        int s = binarySearch(a,0,8);
//
//
//        System.out.println("Master.main  s "+s);



//        ArrayList<String> list=new ArrayList<>();
//        list.add("a");
//        list.add("b");
//        list.add("b");
//        list.add("c");
//        list.add("c");
//        list.add("c");
//
//        for (int i = 0; i < list.size(); i++) {
//            if (list.get(i).equals("b")){
//                list.remove("b");
//            }
//        }
////        lists.forEach(v->{
////            if (v.equals("b")){
////                lists.remove("b");
////            }
////        });
////        Iterator<String> iterator = list.iterator();
////        while (iterator != null && iterator.hasNext()){
////            if (iterator.next().equals("b")){
////                iterator.remove();
////            }
////        }
//        System.out.println("Master.main "+list);
//
//        Integer[] arr = {1,2,3};
//        ArrayList list1 = new ArrayList(Arrays.asList(arr));
//        System.out.println("Master.main "+list1.size());
//        for (int i = 0; i < list1.size(); i++) {
//            System.out.println("Master.main !!!!!!!! "+list1.get(i));
//        }
//
//        String[] strings = new String[]{"a","b","c"};
//        ArrayList<String> imgs = new ArrayList<String>(Arrays.asList(strings));
//
//        System.out.println("Master.main  imgs "+imgs.size());
//        Executors.newCachedThreadPool()
    }

    static void testArrayMap(){
        ArrayMap<String,String> arrayMap = new ArrayMap<>(3);
        arrayMap.put("a","A");
        arrayMap.put("b","B");
        arrayMap.put("c","C");
        arrayMap.put("cjl","CJL");
        System.out.println("Master.main before arrayMap:"+arrayMap);
        arrayMap.clear();
        System.out.println("Master.main XXXXXXXXXX");
        System.out.println("Master.main after arrayMap:"+arrayMap);


        System.out.println("Master.main arrayMap.mBaseCacheSize "+arrayMap.mBaseCacheSize);
        System.out.println("Master.main arrayMap.mBaseCache "+Arrays.deepToString(arrayMap.mBaseCache));



        arrayMap.put("e","E");
        arrayMap.put("f","F");
        arrayMap.put("i","I");
        arrayMap.put("j","J");


        System.out.println("Master.main arrayMap "+arrayMap);
    }

    static int binarySearch(int[] array, int size, int value) {
        int lo = 0;
        int hi = size - 1;
        while (lo <= hi) {
            System.out.println("Master.binarySearch --------------");
            System.out.println("Master.binarySearch  lo "+lo);
            System.out.println("Master.binarySearch  hi "+hi);

            final int mid = (lo + hi) >>> 1;
            System.out.println("Master.binarySearch  mid "+mid);
            final int midVal = array[mid];
            System.out.println("Master.binarySearch  midVal "+midVal);


            if (midVal < value) {
                lo = mid + 1;
            } else if (midVal > value) {
                hi = mid - 1;
            } else {
                return mid;  // value found
            }
        }
        System.out.println("Master.binarySearch  end lo "+lo);
        return ~lo;  // value not present
    }


}
